package com.microstation.service.impl.view;

import java.util.List;

import com.microstation.enums.ResultEnum;
import com.microstation.exception.ElementEmptyException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.microstation.service.view.UserQuesRecViewService;
import com.microstation.dao.view.UserQuesRecViewDao;
import com.microstation.common.Assist;
import com.microstation.common.Result;
import com.microstation.entity.po.view.UserQuesRecView;

/**
 * UserQuesRecView的服务接口的实现类
 *
 * @author
 */
@Service
public class UserQuesRecViewServiceImpl implements UserQuesRecViewService {
    private final Logger LOG = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private UserQuesRecViewDao userQuesRecViewDao;

    @Override
    public Result find(UserQuesRecView userQuesRecView, Assist assist) {
        long results = userQuesRecViewDao.getUserQuesRecViewRowCount(userQuesRecView);
        List<UserQuesRecView> result = userQuesRecViewDao.selectUserQuesRecView(userQuesRecView, assist);
        return new Result(results, result);
    }

    @Override
    public Integer saveNotNull(UserQuesRecView value) {
        if (value == null) {
            return null;
        }
        if (value.getActId() == null) {
            throw new ElementEmptyException(ResultEnum.EMPTY.getInfo());
        }
        int result = userQuesRecViewDao.insertNotNullUserQuesRecView(value);
        return result;
    }

    @Override
    public List<UserQuesRecView> findList(UserQuesRecView userQuesRecView, Assist assist) {
        return userQuesRecViewDao.selectUserQuesRecView(userQuesRecView, assist);
    }

    @Override
    public Long count(UserQuesRecView userQuesRecView) {
        return userQuesRecViewDao.getUserQuesRecViewRowCount(userQuesRecView);
    }
}